package com.example.yiwei.crm.entity;

import android.util.Log;

import com.example.yiwei.crm.entity.ApointmentEntity;
import com.example.yiwei.crm.entity.CommunicateLogEntity;
import com.example.yiwei.crm.entity.CustomerMessageEntity;
import com.example.yiwei.crm.util.NetWorkUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/12/7.
 */

public class customerJson {
    public static List<CustomerMessageEntity> jsonCustomerSimpleMessage(String strUrl, String parameter) {
        List<CustomerMessageEntity> customerList;
        // 获取String url
        Log.d("", strUrl);
        String result = NetWorkUtils.getCount(strUrl, parameter);
        try {
            JSONObject object = new JSONObject(result);
            String boolen = object.getString("boolen");
            if (boolen.equals("success")) {
                customerList = new ArrayList<CustomerMessageEntity>();
                JSONArray array = object.getJSONArray("list");
                for (int i = 0; i < array.length(); i++) {
                    CustomerMessageEntity customer = new CustomerMessageEntity();
                    JSONObject json = array.getJSONObject(i);
                    if (json.has("KAA01")) {
                        customer.setClient_id(json.getInt("KAA01"));
                    }
                    if (json.has("KAA02")) {
                        customer.setClient_name(json.getString("KAA02"));
                    }
                    if (json.has("AKB03")) {
                        customer.setDisease_category(json.getString("AKB03"));
                    }
                    if (json.has("CTS01")) {
                        customer.setCreate_time(json.getString("CTS01"));
                    }
                    customerList.add(customer);
                }
                return customerList;
            } else {
                Log.d("", "查询失败");
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }


        return null;
    }

    public static CustomerMessageEntity jsonCustomerDetailedMessage(String result, String paramter) {
        CustomerMessageEntity customer ;
        System.out.print(result);
        try {
            JSONObject object = new JSONObject(result);
                JSONObject json = object.getJSONObject("pd");
                    customer = new CustomerMessageEntity();
                    if (json.has("KAA01")) {
                        customer.setClient_id(json.getInt("KAA01"));
                    }
                    if (json.has("KAA02")) {
                        customer.setClient_name(json.getString("KAA02"));
                    }
                    if (json.has("KAA03")) {
                        customer.setClient_age(json.getInt("KAA03"));
                        Log.d("aa",json.getInt("KAA03")+"");
                    }
                    if (json.has("KAA04")) {
                        customer.setClient_gender(json.getInt("KAA04"));
                    }
                    if (json.has("KAA05")) {
                        customer.setBirthDay(json.getString("KAA05"));
                    }
                    if (json.has("KAA06")) {
                        customer.setPhone_Number(json.getString("KAA06"));
                    }
                    if (json.has("KAA07")) {
                        customer.setIDNumber(json.getString("KAA07"));
                    }
                    if (json.has("KAA08")) {
                        customer.setClient_Address(json.getString("KAA08"));
                    }
                    if (json.has("KAA30")){
                        customer.setPname(json.getString("KAA30"));
                    }
                    if (json.has("KAA31")){
                        customer.setCname(json.getString("KAA31"));
                    }
                    if (json.has("KAA32")){
                        customer.setAname(json.getString("KAA32"));
                    }
                    if (json.has("KAA37")){
                        customer.setHydj(json.getInt("KAA37"));
                    }
                if (json.has("KAA34")){
                    customer.setRhfk(json.getInt("KAA34"));
                }
                    if (json.has("KAA09")) {
                        customer.setClient_Manager(json.getInt("KAA09"));
                    }
                    if (json.has("KAA10L")) {
                        customer.setNext_Time(json.getString("KAA10L"));
                    }
                    if (json.has("KAA11")) {
                        customer.setNext_Content(json.getString("KAA11"));
                    }
                    if (json.has("AKA01")) {
                        customer.setClient_Category_id(json.getInt("AKA01"));
                    }
                    if (json.has("AKC01")) {
                        customer.setChannel_classification_id(json.getInt("AKC01"));
                    }
                    if (json.has("AKD01")) {
                        customer.setChannel_source_id(json.getInt("AKD01"));
                    }
                    if (json.has("AKE01")) {
                        customer.setMedical_class_id(json.getInt("AKE01"));
                    }
                    if (json.has("KAA12")) {
                        customer.setSecurity_numbers(json.getString("KAA12"));
                    }
                    if (json.has("KAA13")) {
                        customer.setZip_Code(json.getString("KAA13"));
                    }
                    if (json.has("KAA14")) {
                        customer.setHome_address(json.getString("KAA14"));
                    }
                    if (json.has("KAA21")) {
                        customer.setIntroducer(json.getString("KAA21"));
                    }
                    if (json.has("AKB01")) {
                        customer.setDisease_category_id(json.getInt("AKB01"));
                    }
                    if (json.has("REK01")) {
                        customer.setAdditional_remarks(json.getString("REK01"));
                    }
                    if (json.has("CTS01L")) {
                        customer.setCreate_time(json.getString("CTS01"));
                    }
                    if (json.has("UTS01L")) {
                        customer.setUpdate_time(json.getString("UTS01"));
                    }
                    if (json.has("CID01")) {
                        customer.setCurrent_create_user_id(json.getString("CID01"));
                    }
                    if (json.has("UID01")) {
                        customer.setCurrent_update_user_id(json.getString("UID01"));
                    }
                    if (json.has("HAA01")) {
                        customer.setReturn_templete_id(json.getInt("HAA01"));
                    }
                    //负责人姓名
                    if (json.has("UAB03")) {
                        customer.setClient_manager_name(json.getString("UAB03"));
                    }
                    //当前创建用户姓名
                    if (json.has("CID03")) {
                        customer.setCurrent_create_user_name(json.getString("CID03"));
                    }
                    //当前更新用户姓名
                    if (json.has("UID01N")) {
                        customer.setCurrent_update_user_name(json.getString("UID01N"));
                    }
                    //是否关注
                    if (json.has("KAA22")) {
                        customer.setIs_attention(json.getInt("KAA22"));
                    }
                    //跟进状态
                    if (json.has("KAA27")) {
                        customer.setFollw_state(json.getInt("KAA27"));
                    }
                    //所属部门
                    if (json.has("UNT01")){
                        customer.setBelongs_department(json.getString("UNT01"));
                    }
                    return customer;

        } catch (JSONException e) {
            e.printStackTrace();
        }


        return null;
    }
    public static CustomerMessageEntity jsonCustomerDetailedMessage1(String result, String paramter) {
        CustomerMessageEntity customer ;
        System.out.print(result);
        try {
            JSONObject object = new JSONObject(result);
            JSONArray array = object.getJSONArray("list");
            JSONObject json = array.getJSONObject(0);
            customer = new CustomerMessageEntity();
            if (json.has("KAA01")) {
                customer.setClient_id(json.getInt("KAA01"));
            }
            if (json.has("KAA02")) {
                customer.setClient_name(json.getString("KAA02"));
            }
            if (json.has("KAA03")) {
                customer.setClient_age(json.getInt("KAA03"));
                Log.d("aa",json.getInt("KAA03")+"");
            }
            if (json.has("KAA04")) {
                customer.setClient_gender(json.getInt("KAA04"));
            }
            if (json.has("KAA05")) {
                customer.setBirthDay(json.getString("KAA05"));
            }
            if (json.has("KXA01")){
                customer.setCoor_id(json.getInt("KXA01"));
            }
            if (json.has("KAA06")) {
                customer.setIDNumber(json.getString("KAA06"));
            }
            if (json.has("KAA07")) {
                customer.setIDNumber(json.getString("KAA07"));
            }
            if (json.has("KAA08")) {
                customer.setClient_Address(json.getString("KAA08"));
            }
            if (json.has("KAA30")){
                customer.setPname(json.getString("KAA30"));
            }
            if (json.has("KAA31")){
                customer.setCname(json.getString("KAA31"));
            }
            if (json.has("KAA32")){
                customer.setAname(json.getString("KAA32"));
            }
            if (json.has("KAA37")){
                customer.setHydj(json.getInt("KAA37"));
            }
            if (json.has("KAA34")){
                customer.setRhfk(json.getInt("KAA34"));
            }
            if (json.has("KAA09")) {
                customer.setClient_Manager(json.getInt("KAA09"));
            }
            if (json.has("KAA10L")) {
                customer.setNext_Time(json.getString("KAA10L"));
            }
            if (json.has("KAA11")) {
                customer.setNext_Content(json.getString("KAA11"));
            }
            if (json.has("AKA01")) {
                customer.setClient_Category_id(json.getInt("AKA01"));
            }
            if (json.has("AKC01")) {
                customer.setChannel_classification_id(json.getInt("AKC01"));
            }
            if (json.has("AKD01")) {
                customer.setChannel_source_id(json.getInt("AKD01"));
            }
            if (json.has("AKE01")) {
                customer.setMedical_class_id(json.getInt("AKE01"));
            }
            if (json.has("AKE03")) {
                customer.setMedical_class(json.getString("AKE03"));
            }
            if (json.has("KAA12")) {
                customer.setSecurity_numbers(json.getString("KAA12"));
            }
            if (json.has("KAA13")) {
                customer.setZip_Code(json.getString("KAA13"));
            }
            if (json.has("KAA14")) {
                customer.setHome_address(json.getString("KAA14"));
            }
            if (json.has("KAA21")) {
                customer.setIntroducer(json.getString("KAA21"));
            }
            if (json.has("AKB01")) {
                customer.setDisease_category_id(json.getInt("AKB01"));
            }
            if (json.has("REK01")) {
                customer.setAdditional_remarks(json.getString("REK01"));
            }
            if (json.has("CTS01L")) {
                customer.setCreate_time(json.getString("CTS01L"));
            }
            if (json.has("UTS01L")) {
                customer.setUpdate_time(json.getString("UTS01L"));
            }
            if (json.has("CID01")) {
                customer.setCurrent_create_user_id(json.getString("CID01"));
            }
            if (json.has("UID01")) {
                customer.setCurrent_update_user_id(json.getString("UID01"));
            }
            if (json.has("HAA01")) {
                customer.setReturn_templete_id(json.getInt("HAA01"));
            }
            //负责人姓名
            if (json.has("UAB03")) {
                customer.setClient_manager_name(json.getString("UAB03"));
            }
            //当前创建用户姓名
            if (json.has("CID03")) {
                customer.setCurrent_create_user_name(json.getString("CID03"));
            }
            //当前更新用户姓名
            if (json.has("UID01N")) {
                customer.setCurrent_update_user_name(json.getString("UID01N"));
            }
            //是否关注
            if (json.has("KAA22")) {
                customer.setIs_attention(json.getInt("KAA22"));
            }
            //跟进状态
            if (json.has("KAA27")) {
                customer.setFollw_state(json.getInt("KAA27"));
            }
            //所属部门
            if (json.has("UNT01N")){
                customer.setBelongs_department(json.getString("UNT01N"));
            }
            return customer;

        } catch (JSONException e) {
            e.printStackTrace();
        }


        return null;
    }

    public static List<Map<String, String>> jsonCustomerSpinnerContent(String result, int l) {
        List<Map<String, String>> list1;
        List<Map<String, String>> list2;
        List<Map<String, String>> list3;
        List<Map<String, String>> list4;
        List<Map<String, String>> list5;
        List<Map<String, String>> list6;
        List<Map<String, String>> list7;
        String inforType;
        try {
            JSONObject object = new JSONObject(result);
            String boolen = object.getString("boolean");
            if (boolen.equals("success")) {
                list1 = new ArrayList<Map<String, String>>();
                list2 = new ArrayList<Map<String, String>>();
                list3 = new ArrayList<Map<String, String>>();
                list4 = new ArrayList<Map<String, String>>();
                list5 = new ArrayList<Map<String, String>>();
                list6 = new ArrayList<Map<String, String>>();
                list7 = new ArrayList<Map<String, String>>();
                JSONArray array = object.getJSONArray("list");
                Object aobject = new Object();
                for (int i = 0; i < array.length(); i++) {
                    Map<String, String> map = new HashMap<String, String>();
                    JSONObject json = array.getJSONObject(i);
                    inforType = json.getString("SIGNVALUE");
                    if ("KHLX".equals(inforType)) {
                        int iKHLX = json.getInt("HAA01");
                        String sKHLX = json.getString("HAA02");
                        map.put("KHLX01", String.valueOf(iKHLX));
                        map.put("KHLX02", sKHLX);
                        list1.add(map);
                    }
                    if ("MB".equals(inforType)) {
                        int iMB = json.getInt("HAA01");
                        String sMB = json.getString("HAA02");
                        map.put("MB01", String.valueOf(iMB));
                        map.put("MB02", sMB);
                        list2.add(map);
                    }
                    if ("BGLX".equals(inforType)) {
                        int iBGLX = json.getInt("HAA01");
                        String sBGLX = json.getString("HAA02");
                        map.put("BGLX01", String.valueOf(iBGLX));
                        map.put("BGLX02", sBGLX);
                        list3.add(map);
                    }
                    if ("QDFL".equals(inforType)) {
                        int iQDFL = json.getInt("HAA01");
                        String sQDFL = json.getString("HAA02");
                        map.put("QDFL01", String.valueOf(iQDFL));
                        map.put("QDFL02", sQDFL);
                        list4.add(map);
                    }
                    if ("QDLY".equals(inforType)) {
                        int iQDLY = json.getInt("HAA01");
                        String sQDLY = json.getString("HAA02");
                        map.put("QDLY01", String.valueOf(iQDLY));
                        map.put("QDLY02", sQDLY);
                        list5.add(map);
                    }
                    if ("YBLX".equals(inforType)) {
                        int iYBLX = json.getInt("HAA01");
                        String sYBLX = json.getString("HAA02");
                        map.put("YBLX01", String.valueOf(iYBLX));
                        map.put("YBLX02", sYBLX);
                        list6.add(map);
                    }
                    if ("BM".equals(inforType)) {
                        int department_id = json.getInt("HAA01");
                        String department = json.getString("HAA02");
                        map.put("BM01", String.valueOf(department_id));
                        map.put("BM02", department);
                        list7.add(map);
                    }


                }
                if (l == 1) {
                    return list1;
                } else if (l == 2) {
                    return list2;
                } else if (l == 3) {
                    return list3;
                } else if (l == 4) {
                    return list4;
                } else if (l == 5) {
                    return list5;
                } else if (l == 6) {
                    return list6;
                } else if (l == 7) {
                    return list7;
                }

            } else {
                Log.d("", "查询失败");
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }


        return null;
    }

    public static List<Map<String, String>> jsonAppointmentSpinner(String result, int l) {
        List<Map<String, String>> list1;
        List<Map<String, String>> list2;
        List<Map<String, String>> list3;
        List<Map<String, String>> list4;
        List<Map<String, String>> list5;
        List<Map<String, String>> list6;
        List<Map<String, String>> list7;
        String inforType;
        try {
            JSONObject object = new JSONObject(result);
            String boolen = object.getString("boolean");
            if (boolen.equals("success")) {
                list1 = new ArrayList<Map<String, String>>();
                list2 = new ArrayList<Map<String, String>>();
                list3 = new ArrayList<Map<String, String>>();
                list4 = new ArrayList<Map<String, String>>();
                list5 = new ArrayList<Map<String, String>>();
                list6 = new ArrayList<Map<String, String>>();
                list7 = new ArrayList<Map<String, String>>();
                JSONArray array = object.getJSONArray("list");
                Object aobject = new Object();
                for (int i = 0; i < array.length(); i++) {
                    Map<String, String> map = new HashMap<String, String>();
                    JSONObject json = array.getJSONObject(i);
                    inforType = json.getString("SIGNVALUE");
                    //预约医院
                    if ("YY".equals(inforType)) {
                        String hospital = "";
                        String hospital_code = json.getString("UAA02");
                        int hospital_id = json.getInt("UAA01");
                        if (json.has("FK")) {
                            hospital = json.getString("FK");
                        }
                        String mark = json.getString("UAA02");
                        map.put("hospital_id", String.valueOf(hospital_id));
                        map.put("hospital", hospital);
                        map.put("mark", mark);
                        map.put("hospitl_code", hospital_code);
                        list1.add(map);
                    }
                    //预约科室
                    if ("KS".equals(inforType)) {
                        String department = "";
                        String mark = "";
                        String department_code = "";
                        int department_id = json.getInt("UAA01");
                        if (json.has("UAA02")) {
                            department_code = json.getString("UAA02");
                        }
                        if (json.has("FK")) {
                            department = json.getString("FK");
                        }
                        if (json.has("AE")) {
                            mark = json.getString("AE");
                        }
                        map.put("department_id", String.valueOf(department_id));
                        map.put("department", department);
                        map.put("mark", mark);
                        map.put("department_code", department_code);
                        list2.add(map);
                    }
                    //预约医生
                    //病种分类
                    if ("BZFL".equals(inforType)) {
                        String sBZFL = "";
                        int iBZFL = json.getInt("UAA01");
                        if (json.has("FK")) {
                            sBZFL = json.getString("FK");
                        }
                        String mark = json.getString("UAA02");
                        map.put("iBZFL", String.valueOf(iBZFL));
                        map.put("sBZFL", sBZFL);
                        map.put("mark", mark);
                        list4.add(map);
                    }
                    //病种
                    if ("BZ".equals(inforType)) {
                        String sBZ = "";
                        String disease_code = json.getString("UAA02");
                        String mark = "";
                        int iBZ = json.getInt("UAA01");
                        if (json.has("FK")) {
                            sBZ = json.getString("FK");
                        }
                        if (json.has("AE")) {
                            mark = json.getString("AE");
                        }
                        map.put("iBZ", String.valueOf(iBZ));
                        map.put("sBZ", sBZ);
                        map.put("mark", mark);
                        map.put("disease_code", disease_code);
                        list5.add(map);
                    }
                    //渠道分类
                    if ("QDFL".equals(inforType)) {
                        String sQDFL = "";
                        String mark = "";
                        int iQDFL = json.getInt("UAA01");
                        if (json.has("FK")) {
                            sQDFL = json.getString("FK");
                        }
                        if (json.has("UAA01")) {
                            mark = json.getString("UAA01");
                        }
                        map.put("QDFL01", String.valueOf(iQDFL));
                        map.put("QDFL02", sQDFL);
                        map.put("mark", mark);
                        list6.add(map);
                    }
                    //渠道来源
                    if ("QDLY".equals(inforType)) {
                        String sQDLY = "";
                        String mark = "";
                        int iQDLY = json.getInt("UAA02");
                        if (json.has("FK")) {
                            sQDLY = json.getString("FK");
                        }
                        if (json.has("UAA02")) {
                            mark = json.getString("UAA02");
                        }
                        map.put("QDLY01", String.valueOf(iQDLY));
                        map.put("QDLY02", sQDLY);
                        map.put("mark", mark);
                        list7.add(map);
                    }

                }
                if (l == 1) {
                    return list1;

                } else if (l == 2) {
                    return list2;
                } else if (l == 3) {
                    return list3;
                } else if (l == 4) {
                    return list4;
                } else if (l == 5) {
                    return list5;
                } else if (l == 6) {
                    return list6;
                } else if (l == 7) {
                    return list7;
                }

            } else {
                Log.d("", "查询失败");
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static List<ApointmentEntity> jsonCustomerAppointmentSimpleMessage(String strUrl, String parameter) {
        String result = NetWorkUtils.getCount(strUrl, parameter);
        List<ApointmentEntity> apointmentEntityList;
        try {
            JSONObject JSON = new JSONObject(result);
            String BOOLEN = JSON.getString("boolen");
            if ("success".equals(BOOLEN)) {
                apointmentEntityList = new ArrayList<>();
                JSONArray array = JSON.getJSONArray("list");
                for (int i = 0; i < array.length(); i++) {
                    ApointmentEntity apointmentEntity = new ApointmentEntity();
                    JSONObject object = array.getJSONObject(i);
                    //预约ID
                    if (object.has("KYA01")) {
                        apointmentEntity.setAppoint_id(object.getInt("KYA01"));
                    }
                    //预约时间
                    if (object.has("KYA02")) {
                        apointmentEntity.setAppoint_date(object.getString("KYA02"));
                    }
                    //预约医院
                    if (object.has("UAA03")) {
                        apointmentEntity.setAppoint_hospital(object.getString("UAA03"));
                    }
                    //预约科室
                    if (object.has("ADD03")) {
                        apointmentEntity.setAppint_department(object.getString("ADD03"));
                    }
                    //预约医生
                    if (object.has("ADE03")) {
                        apointmentEntity.setAppoint_doctor(object.getString("ADE03"));
                    }
                    //预约病种分类ID
                    if (object.has("AKB01")) {
                        apointmentEntity.setDisease_category_id(object.getInt("AKB01"));
                    }
                    //预约病种
                    if (object.has("AKM03")) {
                        apointmentEntity.setDisease(object.getString("AKM03"));
                    }
//                    预约备注
                    if (object.has("KYA03")) {
                        apointmentEntity.setAppoint_additional(object.getString("KYA03"));
                    }
                    //未到原因
                    if (object.has("KYA14")) {
                        apointmentEntity.setNo_reason(object.getInt("KYA14"));
                    }
                    //状态
                    if (object.has("KYA13")) {
                        apointmentEntity.setAppointment_state(object.getInt("KYA13"));
                    }
                    //预约号
                    if (object.has("KYA11")) {
                        apointmentEntity.setAppointment_number(object.getString("KYA11"));
                    }
                    apointmentEntityList.add(apointmentEntity);
                }
                return apointmentEntityList;
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static ApointmentEntity jsonCustomerAppointmentDetailedMessage(String strUrl, String parameter) {
              ApointmentEntity apointmentEntity;
              String result= NetWorkUtils.getCount(strUrl,parameter);
        try {
            JSONObject object1=new JSONObject(result);
            String boolen=object1.getString("boolen");
            if ("success".equals(boolen)) {
                JSONArray array = object1.getJSONArray("list");
                for (int i = 0; i < array.length(); i++) {
                    apointmentEntity = new ApointmentEntity();
                    JSONObject object = array.getJSONObject(i);
                    //预约时间
                    if (object.has("KYA02")) {
                        apointmentEntity.setAppoint_date(object.getString("KYA02"));
                    }
                    //预约医院
                    if (object.has("UAA03")) {
                        apointmentEntity.setAppoint_hospital(object.getString("UAA03"));
                        Log.d("kkkkk",object.getString("UAA03"));
                    }
                    //预约科室
                    if (object.has("ADD03")) {
                        apointmentEntity.setAppint_department(object.getString("ADD03"));
                    }
                    //预约医生
                    if (object.has("ADE03")) {
                        apointmentEntity.setAppoint_doctor(object.getString("ADE03"));
                    }
                    //预约病种分类ID
                    if (object.has("AKB01")) {
                        apointmentEntity.setDisease_category_id(object.getInt("AKB01"));
                    }
                    //预约病种
                    if (object.has("AKM03")) {
                        apointmentEntity.setDisease(object.getString("AKM03"));
                    }
//                    预约备注
                    if (object.has("KYA03")) {
                        apointmentEntity.setAppoint_additional(object.getString("KYA03"));
                    }
                    //未到原因
                    if (object.has("KYA14")) {
                        apointmentEntity.setNo_reason(object.getInt("KYA14"));
                    }
                    //状态
                    if (object.has("KYA13")) {
                        apointmentEntity.setAppointment_state(object.getInt("KYA13"));
                    }
                    //预约号
                    if (object.has("KYA11")) {
                        apointmentEntity.setAppointment_number(object.getString("KYA11"));
                    }
                    return apointmentEntity;
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static List<ApointmentEntity> jsonTriageMessage(String URL, String PARA){
        List<ApointmentEntity> list;
        ApointmentEntity apointmentEntity;
        String result= NetWorkUtils.getCount(URL,PARA);
        try {
            JSONObject json=new JSONObject(result);
            String boolen=json.getString("boolen");
            if ("success".equals(boolen)){
                list=new ArrayList<>();
                JSONArray array=json.getJSONArray("list");
                for (int i=0;i<array.length();i++){
                    apointmentEntity = new ApointmentEntity();
                    JSONObject object = array.getJSONObject(i);
                    //客户名
                    if (object.has("KAA02")){
                        apointmentEntity.setCustomer_name(object.getString("KAA02"));
                    }
                    //预约时间
                    if (object.has("KYA02")) {
                        apointmentEntity.setAppoint_date(object.getString("KYA02"));
                    }
                    //状态
                    if (object.has("KAA27")) {
                        apointmentEntity.setAppointment_state(object.getInt("KAA27"));
                    }
                    //预约号
                    if (object.has("KYA11")) {
                        apointmentEntity.setAppointment_number(object.getString("KYA11"));
                    }
                    //预约ID
                    if (object.has("KYA01")){
                        apointmentEntity.setAppoint_id(object.getInt("KYA01"));
                    }
                    list.add(apointmentEntity);


                }
                return list;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static ApointmentEntity jsonAllTriageMessage(String url, String para){
        ApointmentEntity apointmentEntity;
        String result= NetWorkUtils.getCount(url,para);
        try {
            JSONObject JSON=new JSONObject(result);
            String boolen=JSON.getString("boolen");
            if ("success".equals(boolen)){
                apointmentEntity=new ApointmentEntity();
                JSONArray array=JSON.getJSONArray("list");
                for (int i=0;i<array.length();i++){
                    JSONObject object=array.getJSONObject(i);
                    //状态
                    if (object.has("KYA13")){
                        apointmentEntity.setAppointment_state(object.getInt("KYA13"));
                    }
                    //客户名
                    if (object.has("KAA02")){
                        apointmentEntity.setCustomer_name(object.getString("KAA02"));
                    }
                    //性别
                    if (object.has("KAA04")){
                        apointmentEntity.setCustomer_gender(object.getInt("KAA04"));
                    }
                    //年龄
                    if (object.has("KAA03")){
                        apointmentEntity.setCustomer_age(object.getInt("KAA03"));
                    }
                    //疾病类型
                    if (object.has("AKB03")){
                        apointmentEntity.setDisease_category(object.getString("AKB03"));
                    }
                    //手机
                    if (object.has("KLA06")){
                        apointmentEntity.setContact_phone_number(object.getString("KLA06"));
                    }
                    //地址
                   if (object.has("KAA08")){
                       apointmentEntity.setCustomer_address(object.getString("KAA08"));
                   }
                    //预约号
                    if (object.has("KYA11")) {
                        apointmentEntity.setAppointment_number(object.getString("KYA11"));
                    }
                    //预约时间
                    if (object.has("KYA02")) {
                        apointmentEntity.setAppoint_date(object.getString("KYA02"));
                    }
                    //预约科室
                    if (object.has("ADD03")) {
                        apointmentEntity.setAppint_department(object.getString("ADD03"));
                    }
                    //预约医生
                    if (object.has("ADE03")) {
                        apointmentEntity.setAppoint_doctor(object.getString("ADE03"));
                    }
                    //分诊号
                    if (object.has("KYA12")){
                        apointmentEntity.setTriage_number(object.getString("KYA12"));
                    }
                    //分诊时间
                    if (object.has("KYA09")){
                        apointmentEntity.setTriage_date(object.getString("KYA09"));
                    }
                    //分诊科室
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }
    public static List<CustomerMessageEntity> jsonSimpleReceiveCustomerMessage(String url, String para){
        List<CustomerMessageEntity> list;
        CustomerMessageEntity customer;
        String result= NetWorkUtils.getCount(url,para);
         try {
                JSONObject object=new JSONObject(result);
                String boolen=object.getString("boolen");
                if ("success".equals(boolen)){
                list=new ArrayList<>();
                JSONArray array=object.getJSONArray("list");
                for (int i=0;i<array.length();i++) {
                    customer = new CustomerMessageEntity();
                    JSONObject json = array.getJSONObject(i);
                    //客户ID
                    if (json.has("KAA01")) {
                        customer.setClient_id(json.getInt("KAA01"));
                    }

                    //客户名
                    if (json.has("KAA02")) {
                        customer.setClient_name(json.getString("KAA02"));
                    }
                    //年龄
                    if (json.has("KAA03")) {
                        customer.setClient_age(json.getInt("KAA03"));
                    }
                    //性别
                    if (json.has("KAA04")) {
                        customer.setClient_gender(json.getInt("KAA04"));
                    }
                    //主要联系人
                    if (json.has("KLA02")) {
                        customer.setMainContact(json.getString("KLA02"));
                    }
                    //联系电话
                    if (json.has("KLA06")) {
                        customer.setContact_phone_number(json.getString("KLA06"));
                    }
                    //疾病种类
                    if (json.has("AKB03")) {
                        customer.setDisease_category(json.getString("AKB03"));
                    }
                    //下次联系时间
                    if (json.has("KAA10")) {
                        customer.setNext_Time(json.getString("KAA10"));
                    }
                    //下次联系内容
                    if (json.has("KAA11")) {
                        customer.setNext_Content(json.getString("KAA11"));
                    }
                    //渠道来源
                    if (json.has("AKD03")) {
                        customer.setChannel_source(json.getString("AKD03"));
                    }
                    //所属部门
                    if (json.has("UAA03")) {
                        customer.setBelongs_department(json.getString("UAA03"));
                    }
                    //接诊医生
                    if (json.has("KYA06")) {
                        customer.setRecevie_doctor(json.getString("KYA06"));
                    }
                    //负责人姓名
                    if (json.has("FNAME")) {
                        customer.setClient_manager_name(json.getString("FNAME"));
                    }
                    //当前创建用户姓名
                    if (json.has("CNAME")) {
                        customer.setCurrent_create_user_name(json.getString("CNAME"));
                    }
                    //跟进状态
                    if (json.has("KAA27")) {
                        customer.setFollw_state(json.getInt("KAA27"));
                    }
                    //创建时间
                    if (json.has("CTS01")) {
                        customer.setCreate_time(json.getString("CTS01"));
                    }
                    list.add(customer);
                }
                return list;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;

    }
    public static CustomerMessageEntity jsonDetailedReceiveCustomerMessage(String url, String para) {
        CustomerMessageEntity customer;
        String result= NetWorkUtils.getCount(url,para);
        try {
            JSONObject object=new JSONObject(result);
            String boolen=object.getString("boolen");
            if ("success".equals(boolen)){
                JSONArray array=object.getJSONArray("list");
                for (int i=0;i<array.length();i++){
                    customer=new CustomerMessageEntity();
                    customer.setTag(boolen);
                    JSONObject json=array.getJSONObject(i);
                    if (json.has("KAA01")) {
                        customer.setClient_id(json.getInt("KAA01"));
                    }
                    if (json.has("KAA02")) {
                        customer.setClient_name(json.getString("KAA02"));
                    }
                    if (json.has("KAA03")) {
                        customer.setClient_age(json.getInt("KAA03"));
                    }
                    if (json.has("KAA04")) {
                        customer.setClient_gender(json.getInt("KAA04"));
                    }
                    if (json.has("KAA05")) {
                        customer.setBirthDay(json.getString("KAA05"));
                    }
                    if (json.has("KAA06")) {
                        customer.setPhone_Number(json.getString("KAA06"));
                    }
                    if (json.has("KAA07")) {
                        customer.setIDNumber(json.getString("KAA07"));
                    }
                    if (json.has("KAA08")) {
                        customer.setClient_Address(json.getString("KAA08"));
                    }
                    if (json.has("KAA09")) {
                        customer.setClient_Manager(json.getInt("KAA09"));
                    }
                    if (json.has("KAA10")) {
                        customer.setNext_Time(json.getString("KAA10"));
                    }
                    if (json.has("KAA11")) {
                        customer.setNext_Content(json.getString("KAA11"));
                    }
                    if (json.has("AKA01")) {
                        customer.setClient_Category_id(json.getInt("AKA01"));
                    }
                    if (json.has("AKC01")) {
                        customer.setChannel_classification_id(json.getInt("AKC01"));
                    }
                    if (json.has("AKD01")) {
                        customer.setChannel_source_id(json.getInt("AKD01"));
                    }
                    if (json.has("AKE01")) {
                        customer.setMedical_class_id(json.getInt("AKE01"));
                    }
                    if (json.has("KAA12")) {
                        customer.setSecurity_numbers(json.getString("KAA12"));
                    }
                    if (json.has("KAA13")) {
                        customer.setZip_Code(json.getString("KAA13"));
                    }
                    if (json.has("KAA14")) {
                        customer.setHome_address(json.getString("KAA14"));
                    }
                    if (json.has("KAA21")) {
                        customer.setIntroducer(json.getString("KAA21"));
                    }
                    if (json.has("AKB01")) {
                        customer.setDisease_category_id(json.getInt("AKB01"));
                    }
                    if (json.has("REK01")) {
                        customer.setAdditional_remarks(json.getString("REK01"));
                    }
                    if (json.has("CTS01")) {
                        customer.setCreate_time(json.getString("CTS01"));
                    }
                    if (json.has("UTS01")) {
                        customer.setUpdate_time(json.getString("UTS01"));
                    }
                    if (json.has("CID01")) {
                        customer.setCurrent_create_user_id(json.getString("CID01"));
                    }
                    if (json.has("UID01")) {
                        customer.setCurrent_update_user_id(json.getString("UID01"));
                    }
                    if (json.has("HAA01")) {
                        customer.setReturn_templete_id(json.getInt("HAA01"));
                    }
                    //负责人姓名
                    if (json.has("FNAME")) {
                        customer.setClient_manager_name(json.getString("FNAME"));
                    }
                    //当前创建用户姓名
                    if (json.has("CNAME")) {
                        customer.setCurrent_create_user_name(json.getString("CNAME"));
                    }
                    //当前更新用户姓名
                    if (json.has("UNAME")) {
                        customer.setCurrent_update_user_name(json.getString("UNAME"));
                    }
                    //是否关注
                    if (json.has("KAA22")) {
                        customer.setIs_attention(json.getInt("KAA22"));
                    }
                    //跟进状态
                    if (json.has("KAA27")) {
                        customer.setFollw_state(json.getInt("KAA27"));
                    }
                    //院内负责人
//                    if (json.has("YFNAME")){
//                        customer.setManager_in_hospital(json.getString("YFNAME"));
//                    }
                   return customer;
                }

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;

    }
public static List<CommunicateLogEntity> jsonCommunicateLog(String url, String para){
    String result= NetWorkUtils.getCount(url,para);
    List<CommunicateLogEntity> list;
    CommunicateLogEntity communicate;
    try {
        JSONObject object=new JSONObject(result);
        String boolen=object.getString("boolean");
        JSONArray array=object.getJSONArray("list");
        if ("success".equals(boolen)) {
            list=new ArrayList<>();
            for (int i=0;i<array.length();i++){
                communicate=new CommunicateLogEntity();
                JSONObject json=array.getJSONObject(i);
                //沟通日志ID
                if (json.has("KGA01")){
                    communicate.setCommunication_id(json.getInt("KGA01"));
                }
                //沟通主题
                if (json.has("KGA02")){
                    communicate.setCommunication_theme(json.getString("KGA02"));
                }
                //沟通内容
                if (json.has("KGA03")){
                    communicate.setCommunication_content(json.getString("KGA03"));
                }
                //下次联系时间
                if (json.has("KGA04")){
                    communicate.setNext_communicate_date(json.getString("KGA04"));
                }
                //下次联系内容
                if (json.has("KGA05")){
                    communicate.setNext_communicate_content(json.getString("KGA05"));
                }
                //创建人
                if (json.has("UAB03")){
                    communicate.setCreate_name(json.getString("UAB03"));
                }
                //创建时间
                if (json.has("CTS01")){
                    communicate.setCreate_time(json.getString("CTS01"));
                }
                list.add(communicate);
            }
            return list;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}
public static List<CustomerMessageEntity> queryMineAllCustomer(String url, String para){
    List<CustomerMessageEntity> customerList = null;
    // 获取String url
    String result = NetWorkUtils.getCount(url, para);
    try {
        JSONObject object = new JSONObject(result);
        String boolen = object.getString("boolen");
        if (boolen.equals("success")) {
            customerList = new ArrayList<CustomerMessageEntity>();
            JSONArray array = object.getJSONArray("list");
            for (int i = 0; i < array.length(); i++) {
                CustomerMessageEntity customer = new CustomerMessageEntity();
                JSONObject json = array.getJSONObject(i);
                if (json.has("KAA01")) {
                    customer.setClient_id(json.getInt("KAA01"));
                }
                if (json.has("KAA02")) {
                    customer.setClient_name(json.getString("KAA02"));
                }
                if (json.has("AKB03")) {
                    customer.setDisease_category(json.getString("AKB03"));
                }
                if (json.has("CTS01")) {
                    customer.setCreate_time(json.getString("CTS01"));
                }
                customerList.add(customer);
            }
            return customerList;
        } else {
            Log.d("", "查询失败");
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }

    return null;
}

}
